<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <title>{$sys_name} - 重置密码</title>
  <!-- Bootstrap -->
  <link href="/css/css/bootstrap.min.css" rel="stylesheet">
  <link href="/css/css/reset.css" rel="stylesheet">
  <link href="/css/css/style.css" rel="stylesheet">
  <script src="/js/js/jquery-1.11.3.min.js" type="text/javascript" ></script>
  <script src="/js/js/respond.js" type="text/javascript" ></script>
  <script src="/js/js/echarts.common.min.js" type="text/javascript" ></script>
  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body class="login_bg">
<div class="login_logo">
  <dl>
    <dt><img src="/images/login_logo.png" alt=""></dt>
    <dd>
      <p>{$sys_name}</p>
				<span>
					<em></em>
					<small>
                      LTC Kingdom
                    </small>
					<em></em>
				</span>
    </dd>
  </dl>
</div>
<div class="clear"></div>
<div class="login_list">
  <div class="login_title">
    <ul>
      <li style="width: 100%"  class="login_cur"><a style="cursor: pointer;width: 80px">{$lang.resetpwd}</a></li>
    </ul>
  </div>
  <div class="login_form">
    <form action="{:U('Index/findPwd')}" id="loginform" method="post">
      <div class="login_in">
        <dl>
          <dt><img src="/images/login1.png" alt=""></dt>
          <dd style="width: 80%"><input type="text" style="width: 100%" class="l_in" placeholder="请输入邮箱地址" value="" name="username" id="username" onchange="checkuname()" ></dd>
          <span id="checkreg_eml" style="position: absolute; margin-left: -6.5rem; color: red"></span>
        </dl>
      </div>
      <div class="login_in">
        <dl>
          <dt><img src="/images/login2.png" alt=""></dt>
          <dd style="width: 80%"><input type="password" style="width: 100%" class="l_in" placeholder="请输入新密码" value="" name="password" id="password"></dd>
        </dl>
      </div>


      <div class="login_yzm" style="">
        <input type="text" class="yzm_in" id="code"  name="code" placeholder="email安全码">
        <span type="button" class="yzm" onclick="send_eml()" style="cursor: pointer" id="yzm">{$lang.sendemail}</span>
      </div>

      <div class="login_btn">
        <input name="doSubmit" type="submit" style="float: left" class="btn_login" id="btnLogin"  value="{$lang.resetpwd}">
        <input name="doSubmit" type="button" style="float: left" class="btn_login" id="" onclick="login()"  value="{$lang.relogin}">
      </div>
    </form>
  </div>
</div>

<!--信息框-->
<include file="Public/Home/Showmsg.html" />

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/js/js/bootstrap.js"></script>
<script>
  var time = 60;
  function send_eml(){
    var checkuanme = checkuname();
    if(checkuanme == "true"){
    var email = $("#username").val();
    $.ajax({
      type:"GET",
      url:"{:U('Index/sendEmail')}",
      data:{email:email},
      dataType: "json",
      success:function(data){
        if(data.error == 0){ //发送成功
          var timer=null;
          var t=time;
          var m=0;
          var s=0;
          m=Math.floor(t/60%60);
          m<10&&(m='0'+m);
          s=Math.floor(t%60);
          function countDown(){
            s--;
            s<10&&(s='0'+s);
            if(s.length>=3){
              s=59;
              m="0"+(Number(m)-1);
            }
            if(m.length>=3){
              m='00';
              s='00';
              clearInterval(timer);
            }

            document.getElementById("yzm").innerHTML="已发送 ("+ s +")";
            document.getElementById("yzm").onclick="";
            if(s == '00'){
              document.getElementById("yzm").innerHTML="发送邮箱安全码";
              document.getElementById("yzm").onclick= send_eml;
            }
            console.log(s);
          }
          timer=setInterval(countDown,1000);
        }else{
          document.getElementById("showmsg").innerHTML=data.msg;
          $("#sysmsg").show();
        }
      }
    });
  }
  }

  var reg = false;
  function checkuname() {
    var uname = document.getElementById("username").value;
    var obj = document.getElementById("checkreg_eml"); // 获取对象
    $.ajax({
      type: "GET",
      url: "{:U('Index/check')}",
      data: {uname: uname},
      dataType: "json",
      success: function (data) {
        if (data != null) {         /*将返回的信息写入对象*/
          if (data != '') {
            obj.innerHTML = data;
            document.getElementById("yzm").onclick = "";
            reg = false;
          } else {
            obj.innerHTML = "";
            document.getElementById("yzm").onclick = send_eml;
            reg = true;
          }
        }
      }
    });
    if(reg == false){
      return "false";
    }else{
      return "true";
    }
  }
  function login(){
    window.location.href = "{:U('Index/login')}";
  }
</script>
</body>
</html>



